<?php

namespace Liuhelong\LaravelAdmin\Wechat;

use Illuminate\Support\ServiceProvider;

use Liuhelong\LaravelAdmin\Wechat\Console\Commands\CreateMenu;
use Liuhelong\LaravelAdmin\Wechat\Console\Commands\Install;
use Liuhelong\LaravelAdmin\Wechat\Services\Wechat;

class LaravelAdminWechatServiceProvider extends ServiceProvider
{
    /**
     * {@inheritdoc}
     */
	protected $commands = [
        CreateMenu::class,
        Install::class,
    ];

    public function register()
    {
        $this->commands($this->commands);
		$this->app->singleton('liuhelong_wechat_service', function ($app) {
            return new Wechat();
        });
    }
	
    public function boot(LaravelAdminWechat $extension)
    {
        if (! LaravelAdminWechat::boot()) {
            return ;
        }

        if ($views = $extension->views()) {
            $this->loadViewsFrom($views, 'laravel-admin-wechat');
        }

        if ($this->app->runningInConsole() && $assets = $extension->assets()) {
            $this->publishes(
                [
					__DIR__.'/../database' => database_path(),
					__DIR__.'/../routes' => base_path('routes'),
					__DIR__.'/../resources/lang' => base_path('resources/lang/zh-CN'),
					//如果 事件方法想自定义，下面这行可以删掉
					__DIR__.'/../src/Functions' => base_path('app/Wechat'),
					//暂时没有静态文件要发布
					//$assets => public_path('vendor/liuhelong/laravel-admin/wechat')
				],
                'laravel-admin-wechat'
            );
        }
		if (file_exists($routes = base_path('routes/laravel_admin_wechat.php'))) {
            $this->loadRoutesFrom($routes);
        }
    }
}